
import { View } from "@tarojs/components"
import { CSSProperties } from "react"
import "./badge.scss"

interface BadgeProps {
    text?: string,
    backgroundColor?: string,
    textColor?: string,
    offsetX?: number,
    offsetY?: number
}

const Badge = (props: BadgeProps) => {

    let style: CSSProperties = {
        display: props.text ? "block" : "none", 
        backgroundColor: props.backgroundColor,
        color: props.textColor
    }

    if (props.offsetX) {
        style.right = props.offsetX + "rpx"
    }

    if (props.offsetY) {
        style.top = props.offsetY + "rpx"
    }

    return (
        <View className="badge" 
            style={style}>
            { props.text }
        </View>
    )
}

export default Badge